package com.investmenttechnologyservices.model;


import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.Link;

public class Bank extends EntityHolder {
	//@Id 
	//private String key; // ID
	//private String name;
	//private String org;
	//private String fiId;
	//@Unindexed 
	//private Link fiUrl;
	//private String brokerId;
	//private Boolean sourcedFromOFX = true;
	//private Key regionKey; // Used to get the banking holidays
	
	public Bank(Entity entity) {
		super(entity);
	}
	
	public Bank(String id) {
	    super("bank", id);
	}

	public Bank(String id, String name, String org, String fiId, Link fiUrl, String brokerId, Key regionKey) {
		this(id);
		setName(name);
		setFiId(fiId);
		setOrg(org);
		setFiUrl(fiUrl);
		setBrokerId(brokerId);
		setRegionKey(regionKey);
	}
	
	public Bank(String id, String name, String org, String fiId, Link fiUrl, String brokerId) {
		this(id, name, fiId, org, fiUrl, brokerId, null);
	}

	public Key getKey() {return super.getKey();}
	
	public String getName() {
		return (String) getProperty("name");
	}

	public void setName(String name) {
		setProperty("name", name);
	}
	
	public void setOrg(String org) {
		setUnindexedProperty("org", org);
	}
	
	public String getOrg() {
		return (String) getProperty("org");
	}
	
	public void setFiId(String fiId) {
		setUnindexedProperty("fiId", fiId);
	}
	
	public String getFiId() {
		return (String) getProperty("fiId");
	}
	
	public void setFiUrl(Link fiUrl) {
		setUnindexedProperty("fiUrl", fiUrl);
	}
	
	public Link getFiUrl() {
		return (Link) getProperty("fiUrl");
	}
	
	public void setBrokerId(String brokerId) {
		setProperty("brokerId", brokerId);
	}
	
	public String getBrokerId() {
		return (String) getProperty("brokerId");
	}
	
	public void setSourcedFromOFX(Boolean sourcedFromOFX) {
		setUnindexedProperty("sourcedFromOFX", sourcedFromOFX);
	}
	
	public Boolean getSourcedFromOFX() {
		return (Boolean) getProperty("sourcedFromOFX");
	}
	
	public Key getRegionKey() {
		return (Key)getProperty("region");
	}
	
	public void setRegionKey(Key regionKey) {
		if (regionKey == null) {
			regionKey = KeyFactory.createKey("region", "world");
		}
		setProperty("regionKey",regionKey);
	}

	
}
